<template>
  <div>
    <InnerPageTable ref="userTable" :config="pageTableConfig">
    </InnerPageTable>
  </div>
</template>

<script>
export default {
  data() {
    return {
      columns: [
        {
          title: '系统',
          key: 'title',
        },
        {
          title: '操作',
          align: 'left',
          fixed: 'right',
          width: 100,
          render: (h, params) => {
            return h('div', [
              h('Upload', {
                class: 'upload',
                props: {
                  actions: 'www.baidu.com'
                },
                style: {
                  // width: '100px',
                  // height: '30px'
                  color: 'red',
                },
                on: {
                  click: () => {
                    console.log("上传附件")
                  }
                }
              }, '上传附件')
            ])
          }
        }
      ],
    }
  },
  props: {
    systemData: {
      type: Array,
      default: () => []
    }
  },
  computed: {
    pageTableConfig() {
      return {
        tableData: this.systemData,
        // tableData: this.tabKey === 'coverStatus' ? [] : this.goalTableData,
        columns: this.columns,
        autoFirst: false, //默认 就是 false, 要配置在这里
        // rowClickHandle: this.onRowClick
      }
    }
  },
  methods: {
    async upload(row) {
      const formData = new FormData()
      formData.append('file', file)
      try {
        const response = await fetch('YOUR_UPLOAD_ENDPOINT_URL', {
          method: 'POST',
          body: formData,
        });

        if (!response.ok) {
          throw new Error('Upload failed');
        }

        const data = await response.json();
        console.log('Upload successful', data);
        // 在这里处理上传成功后的逻辑，例如更新UI或调用其他函数
      } catch (error) {
        console.error('Upload error:', error);
        // 在这里处理上传失败的逻辑，例如显示错误消息
      }
    },
    download() {}
  },
  created() {
    this.$emit('SetTitle', '附件上传与下载')
    this.$emit('SetPageWidth', 1000)
  }
}
</script>

<style lang="less" scoped>
.upload:hover {
  cursor: pointer;
}
</style>